
type RequestFn = () => Promise<any>;
const queue: RequestFn[] = [];

export const HttpQueue = {
  add(fn: RequestFn) {
    queue.push(fn);
  },
  async replayAll() {
    while (queue.length) {
      const fn = queue.shift();
      if (fn) await fn();
    }
  },
  clear() {
    queue.length = 0;
  }
};
